home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / bb2000 / files / BlueGame.dxr / 00175_gamesMasterScript.ls < prev    next >
Encoding:
Text File  |  1998-02-20  |  8.4 KB  |  305 lines

  1. property ancestor, mysteryLocList, nextLoc, policeCounter, policeDelayList, flashTimer, keyPressed, bluesWarnings, beenSetCaught, carMemory
  2. global gCarObj, noWayBubList, locateBubList, policeBubList, RADARSPRITES, BANDSPRITES, LIFESPRITE, CURSORINDEX, COUNTDOWNSTRIP, VIDEOSPRITE
  3.  
  4. on new me
  5.   set ancestor to new(script "carScript")
  6.   return me
  7. end
  8.  
  9. on init me, timeDelayList, locList
  10.   set policeDelayList to timeDelayList
  11.   set mysteryLocList to locList
  12.   set flashTimer to 0
  13.   set bluesWarnings to 3
  14.   set beenSetCaught to 0
  15.   set keyPressed to 0
  16.   set nextLoc to 1
  17.   set policeCounter to 0
  18.   append(the actorList, me)
  19. end
  20.  
  21. on stepFrame me
  22.   mainRoutine(me)
  23.   bubbleRoutine(me)
  24. end
  25.  
  26. on bubbleRoutine me
  27.   if policeBubList <> [] then
  28.     repeat with i = 1 to count(policeBubList)
  29.       customstepframe(getAt(policeBubList, i))
  30.     end repeat
  31.   end if
  32. end
  33.  
  34. on mainRoutine me
  35.   case the frameLabel of
  36.     "normal":
  37.       if nextLoc > 8 then
  38.         cursor(-1)
  39.         killLastGame(1)
  40.         toggleGamePuppets(0)
  41.         go("complete")
  42.       else
  43.         policeRoutine(me)
  44.         radarRoutine(me)
  45.         checkMovement(me)
  46.         flashBand(me)
  47.       end if
  48.     "located":
  49.       set myName to getName(me, nextLoc + (BANDSPRITES - 2))
  50.       set the member of sprite (nextLoc + (BANDSPRITES - 2)) to member (myName & "3.PCT")
  51.       set the member of sprite (nextLoc + (BANDSPRITES - 2)) to member (myName & "1.PCT")
  52.   end case
  53. end
  54.  
  55. on reverseAllPolice me
  56.   if count(the actorList) > 2 then
  57.     repeat with i = 3 to count(the actorList)
  58.       set myObject to getAt(the actorList, i)
  59.       set the goingInReverse of myObject to 1
  60.       set the carXpos of myObject to 1
  61.       set the carYpos of myObject to 1
  62.     end repeat
  63.   end if
  64. end
  65.  
  66. on setCaught me
  67.   reverseAllPolice(me)
  68.   if not beenSetCaught then
  69.     set beenSetCaught to 1
  70.     set bluesWarnings to bluesWarnings - 1
  71.     set the member of sprite LIFESPRITE to member ("lives" & bluesWarnings & ".PCT")
  72.     if bluesWarnings > 0 then
  73.       go("warning")
  74.     else
  75.       set bluesWarnings to 3
  76.       go("jailed")
  77.     end if
  78.   end if
  79. end
  80.  
  81. on checkMovement me
  82.   if the mouseDown then
  83.     evaluateCursorAppearance(me, the CAR of gCarObj, 1)
  84.   else
  85.     if keyPressed = 0 then
  86.       killBubbles(me, noWayBubList)
  87.       evaluateCursorAppearance(me, the CAR of gCarObj, 0)
  88.     else
  89.       cursor(-1)
  90.     end if
  91.   end if
  92. end
  93.  
  94. on createBubble me, whichScript, whichList, whichMember
  95.   if whichList = [] then
  96.     set horPos to the locH of sprite the CAR of gCarObj
  97.     set verPos to the locV of sprite the CAR of gCarObj
  98.     if horPos < 280 then
  99.       set xPos to horPos + 15
  100.       set hCode to 4
  101.     else
  102.       set xPos to horPos - 15
  103.       set hCode to 2
  104.     end if
  105.     if verPos < 180 then
  106.       set yPos to verPos + 15
  107.       set vCode to 1
  108.     else
  109.       set yPos to verPos - 15
  110.       set vCode to 3
  111.     end if
  112.     set bubbleObj to new(script whichScript)
  113.     if voidp(whichMember) then
  114.       set whichMember to getAt(["ste", "don", "mur", "wil", "lou", "tom", "mat", "aln"], nextLoc - 1)
  115.     end if
  116.     appear(bubbleObj, xPos, yPos, whichMember & vCode & hCode & ".PCT", whichList)
  117.   end if
  118. end
  119.  
  120. on killBubbles me, myList
  121.   if myList <> [] then
  122.     repeat with i = 1 to count(myList)
  123.       destroy(getAt(myList, i))
  124.     end repeat
  125.   end if
  126. end
  127.  
  128. on blankCar me, blankState
  129.   if blankState then
  130.     if the memberNum of sprite the CAR of gCarObj > 0 then
  131.       set carMemory to the name of the member of sprite the CAR of gCarObj
  132.       set the memberNum of sprite the CAR of gCarObj to 0
  133.     end if
  134.   else
  135.     set the member of sprite the CAR of gCarObj to member carMemory
  136.   end if
  137. end
  138.  
  139. on policeRoutine me
  140.   set policeDelay to getAt(policeDelayList, nextLoc)
  141.   if policeCounter = 0 then
  142.     createPolice(me)
  143.   else
  144.     if policeCounter > 4 then
  145.       set the locH of sprite COUNTDOWNSTRIP to 0
  146.     else
  147.       if the timer > (policeDelay * 60) then
  148.         createPolice(me)
  149.       else
  150.         set newPos to abs((the timer * (640.0 / (policeDelay * 60))) - 640)
  151.         set the locH of sprite COUNTDOWNSTRIP to newPos
  152.       end if
  153.     end if
  154.   end if
  155.   if the timer > 60 then
  156.     killBubbles(me, policeBubList)
  157.   end if
  158. end
  159.  
  160. on radarRoutine me
  161.   if not (the carIsDrivingHori of gCarObj) and not (the carIsDrivingVert of gCarObj) then
  162.     set radarX to abs(getIndex(me, mysteryLocList, nextLoc, 1) - the finalXpos of gCarObj)
  163.     set radarY to abs(getIndex(me, mysteryLocList, nextLoc, 2) - the finalYpos of gCarObj)
  164.     set radarReading to integer(sqrt(power(radarX, 2) + power(radarY, 2)))
  165.     repeat with i = 1 to 15
  166.       if radarReading < i then
  167.         set the member of sprite (i + (RADARSPRITES - 1)) to member ("lit" & i & ".PCT")
  168.         next repeat
  169.       end if
  170.       set the member of sprite (i + (RADARSPRITES - 1)) to member ("off" & i & ".PCT")
  171.     end repeat
  172.     if (radarX = 0) and (radarY = 0) then
  173.       set nextLoc to nextLoc + 1
  174.       reverseAllPolice(me)
  175.       go("located")
  176.     end if
  177.   end if
  178. end
  179.  
  180. on createPolice me
  181.   createBubble(me, "movingBubbleScript", policeBubList, "roll")
  182.   set policeCounter to policeCounter + 1
  183.   set policeCarObj to new(script "policeScript")
  184.   init(policeCarObj, 13, 9, 2)
  185.   if not soundBusy(2) then
  186.     playSound(me, 2, "siren")
  187.   end if
  188.   startTimer()
  189. end
  190.  
  191. on playSound me, whichChannel, whichSound
  192.   puppetSound(whichChannel, 0)
  193.   puppetSound(whichChannel, member whichSound)
  194. end
  195.  
  196. on flashBand me
  197.   if nextLoc < 8 then
  198.     set flashTimer to flashTimer + 1
  199.     if flashTimer > 10 then
  200.       set flashTimer to 0
  201.       set myName to getName(me, nextLoc + (BANDSPRITES - 1))
  202.       set myID to getID(me, nextLoc + (BANDSPRITES - 1))
  203.       if myID = "2" then
  204.         set the member of sprite (nextLoc + (BANDSPRITES - 1)) to member (myName & "1.PCT")
  205.       else
  206.         set the member of sprite (nextLoc + (BANDSPRITES - 1)) to member (myName & "2.PCT")
  207.       end if
  208.     end if
  209.   end if
  210. end
  211.  
  212. on resetBand me
  213.   repeat with i = BANDSPRITES to BANDSPRITES + 6
  214.     set myName to getName(me, i)
  215.     set the member of sprite i to member (myName & "3.PCT")
  216.   end repeat
  217. end
  218.  
  219. on evaluateCursorAppearance me, whichSprite, mouseDownFlag
  220.   set indexH to the mouseH - the locH of sprite whichSprite
  221.   set indexV to the mouseV - the locV of sprite whichSprite
  222.   set evaluateInMiddleH to (indexH > -21) and (indexH < 21)
  223.   set evaluateNotInMiddleV to (indexV < -20) or (indexV > 20)
  224.   if evaluateInMiddleH then
  225.     if evaluateNotInMiddleV then
  226.       set notInCenter to 1
  227.     else
  228.       set notInCenter to 0
  229.     end if
  230.   else
  231.     set notInCenter to 1
  232.   end if
  233.   if notInCenter then
  234.     set evaluateNegativeX to indexH < 0
  235.     set evaluatePositiveX to indexH > 0
  236.     if evaluatePositiveX then
  237.       set lessThan to indexH
  238.       set greaterThan to -(indexH + 1)
  239.     else
  240.       if evaluateNegativeX then
  241.         set lessThan to -(indexH - 1)
  242.         set greaterThan to indexH
  243.       else
  244.         set lessThan to 0
  245.         set greaterThan to 0
  246.       end if
  247.     end if
  248.     set evaluateNegativeY to indexV > greaterThan
  249.     set evaluatePositiveY to indexV < lessThan
  250.     if evaluateNegativeY and evaluatePositiveY then
  251.       if evaluatePositiveX then
  252.         if mouseDownFlag then
  253.           cursor([CURSORINDEX + 3, CURSORINDEX + 3])
  254.           checkCar(gCarObj, 2)
  255.         else
  256.           cursor([CURSORINDEX + 2, CURSORINDEX + 3])
  257.         end if
  258.       else
  259.         if evaluateNegativeX then
  260.           if mouseDownFlag then
  261.             cursor([CURSORINDEX + 7, CURSORINDEX + 7])
  262.             checkCar(gCarObj, 4)
  263.           else
  264.             cursor([CURSORINDEX + 6, CURSORINDEX + 7])
  265.           end if
  266.         end if
  267.       end if
  268.     else
  269.       if evaluateNegativeY then
  270.         if mouseDownFlag then
  271.           cursor([CURSORINDEX + 5, CURSORINDEX + 5])
  272.           checkCar(gCarObj, 3)
  273.         else
  274.           cursor([CURSORINDEX + 4, CURSORINDEX + 5])
  275.         end if
  276.       else
  277.         if evaluatePositiveY then
  278.           if mouseDownFlag then
  279.             cursor([CURSORINDEX + 1, CURSORINDEX + 1])
  280.             checkCar(gCarObj, 1)
  281.           else
  282.             cursor([CURSORINDEX, CURSORINDEX + 1])
  283.           end if
  284.         end if
  285.       end if
  286.     end if
  287.   else
  288.     if mouseDownFlag then
  289.       cursor([CURSORINDEX + 9, CURSORINDEX + 9])
  290.     else
  291.       cursor([CURSORINDEX + 8, CURSORINDEX + 9])
  292.     end if
  293.   end if
  294. end
  295.  
  296. on getName me, whichSprite
  297.   set myName to the name of the member of sprite whichSprite
  298.   return chars(myName, 1, the length of myName - 5)
  299. end
  300.  
  301. on getID me, whichSprite
  302.   set myName to the name of the member of sprite whichSprite
  303.   return chars(myName, the length of myName - 4, the length of myName - 4)
  304. end
  305.